/*
 * launcher_despacho.cpp
 *
 */

#include "../middleware/CommunicationAdpt.h"
#include "../middleware/CommunicationADP.h"
#include "../channel_common/AgentIdManager.h"
#include "../channel_common/ChannelInterface.h"
#include "../IPC/ProcessAux.h"
#include "../common/Argv.h"
#include "../capa_servicios_distribuidos/QueueLauncher.h"
#include "../middleware/CommunicationVendedor.h"
#include "../control/clienteCommon.h"

int main(int argc, char**argv)
{
	std::string hostName = "vendedor_pc";
	//Toma argumentos (main)
	Argv inArgs(argv);

	//Si se le pasa un argumento tomarlo como hostname
	if (inArgs.getArgc() == 2)
		hostName = inArgs.getArg(1);

	Argv args;
	args.pushArg(hostName);

	channel::ChannelInterface::create(hostName);

	ProcessAux::launchProcess2("./out/channel_out_agente",1,args);
	ProcessAux::launchProcess2("./out/channel_in_agente",1,args);

	middleware::CommunicationAdpt::create(middleware::CommunicationAdpt::VENDEDOR, hostName);
	middleware::CommunicationADP::create(middleware::CommunicationADP::VENDEDOR, hostName);
	middleware::CommunicationVendedor::create(middleware::CommunicationVendedor::VENDEDOR,hostName);

}
